package com.hnkywl.sts.action.base;

import com.hnkywl.sts.service.base.SjzdsyService;
import com.hnkywl.sts.service.base.SjzdzService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-3-29
 * Time: 下午9:48
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/base/sjzdz")
public class SjzdzAction extends SimpleActionSupport {
    private SjzdzService sjzdzService;
    private SjzdsyService sjzdsyService ;
   //编码
    private String bm;
    //字典值ID
    private Long sjzdzId;
    //索引ID
    private Long sjzdsyId;
    /**
     * 获得字典索引下的字典值
     */
    @Action("sjzdz_List")
    public void getsjzdz() {
        if (sjzdsyId != null) {
            this.renderText(this.sjzdsyService.findSjzdz(sjzdsyId) );
        } else {
            this.renderText("[]");
        }
    }
    /**
     * 方法名:     deleteSjzdz
     * 功能描述:   删除数据字典值
     * 输入参数:
     * 异常:      <RuntimeException  Exception>
     */
    @Action("delete_sjzdz")
    public void deleteSjzdz() {
        try {
            this.sjzdzService.deleteSjzdz(sjzdzId);
            renderJson("{\"statusCode\":\"200\", \"message\":\"删除成功！\", \"operationType\":\"delete\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderJson("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }
    //=========getter==setter===============
    public String getBm() {
        return bm;
    }

    public void setBm(String bm) {
        this.bm = bm;
    }

    public Long getSjzdzId() {
        return sjzdzId;
    }

    public void setSjzdzId(Long sjzdzId) {
        this.sjzdzId = sjzdzId;
    }

    public Long getSjzdsyId() {
        return sjzdsyId;
    }

    public void setSjzdsyId(Long sjzdsyId) {
        this.sjzdsyId = sjzdsyId;
    }


    @Autowired
    public void setSjzdsyService(SjzdsyService sjzdsyService) {
        this.sjzdsyService = sjzdsyService;
    }

    @Autowired
    public void setSjzdzService(SjzdzService sjzdzService) {
        this.sjzdzService = sjzdzService;
    }
}
